home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / environ.cpp < prev    next >
C/C++ Source or Header  |  1999-01-01  |  2KB  |  80 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. //  ENVIRON.CPP - Environment Class
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    96/02/29 - Created.
  8. //              96/04/01 - Version 1.03A release.
  9. //
  10. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  11. //              Borland C++ Version 4.5
  12. //
  13. //  Author:     Ian Ashdown, P.Eng.
  14. //              byHeart Software Limited
  15. //              620 Ballantree Road
  16. //              West Vancouver, B.C.
  17. //              Canada V7S 1W3
  18. //              Tel. (604) 922-6148
  19. //              Fax. (604) 987-7621
  20. //
  21. //  Copyright 1994-1996 byHeart Software Limited
  22. //
  23. //  The following source code has been derived from:
  24. //
  25. //    Ashdown, I. 1994. Radiosity: A Programmer's
  26. //    Perspective. New York, NY: John Wiley & Sons.
  27. //
  28. //  It may be freely copied, redistributed, and/or modified
  29. //  for personal use ONLY, as long as the copyright notice
  30. //  is included with all source code files.
  31. //
  32. ////////////////////////////////////////////////////////////
  33.  
  34. #include "environ.h"
  35.  
  36. // Calculate environment extents
  37. void Environ::CalcExtents()
  38. {
  39.   double vx, vy, vz;    // Vertex co-ordinates
  40.   Instance *pinst;      // Instance pointer
  41.  
  42.   // Initialize extents
  43.   max_x = max_y = max_z = -MAX_VALUE;
  44.   min_x = min_y = min_z = MAX_VALUE;
  45.  
  46.   // Walk the instance list
  47.   pinst = pinsthd;
  48.   while (pinst != NULL)
  49.   {
  50.     // Get vertex co-ordinates
  51.     pinst->CalcExtents();
  52.  
  53.     vx = pinst->GetMin_X();
  54.     vy = pinst->GetMin_Y();
  55.     vz = pinst->GetMin_Z();
  56.  
  57.     // Update x-axis extents
  58.     if (vx < min_x)
  59.         min_x = vx;
  60.     if (vy < min_y)
  61.         min_y = vy;
  62.     if (vz < min_z)
  63.         min_z = vz;
  64.  
  65.     vx = pinst->GetMax_X();
  66.     vy = pinst->GetMax_Y();
  67.     vz = pinst->GetMax_Z();
  68.  
  69.     // Update x-axis extents
  70.     if (vx > max_x)
  71.         max_x = vx;
  72.     if (vy > max_y)
  73.         max_y = vy;
  74.     if (vz > max_z)
  75.         max_z = vz;
  76.  
  77.     pinst = pinst->GetNext();
  78.   }
  79. }
  80.